package com.ruoyi.web.controller.pv;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.pv.service.IPvHomeImageService;
import org.springframework.web.multipart.MultipartFile;

/**
 * 主页图片Controller
 *
 * @author zzx
 * @date 2023-05-06
 */
@RestController
@RequestMapping("/pv/home_image")
public class PvHomeImageController extends BaseController {

    @Autowired private IPvHomeImageService pvHomeImageService;

    /**
     * 查询
     */
    @PreAuthorize("@ss.hasPermi('pv:home_image:image')")
    @GetMapping
    public AjaxResult select() {
        return AjaxResult.success(pvHomeImageService.url());
    }

    /**
     * 修改照片
     */
    @PreAuthorize("@ss.hasPermi('pv:home_image:edit')")
    @PutMapping
    public AjaxResult update(MultipartFile file) {
        pvHomeImageService.updatePvHomeImage(file);
        return AjaxResult.success();
    }
}
